﻿Imports System.Web.UI.WebControls

Namespace DotNetNuke.Modules.ActiveForums
    Partial Public Class admin_ranks_new
        Inherits ActiveAdminBase

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            BindRankImages()

        End Sub

        Private Sub agRanks_Callback(ByVal sender As Object, ByVal e As Modules.ActiveForums.Controls.CallBackEventArgs) Handles agRanks.Callback
            agRanks.Datasource = DataProvider.Instance.Ranks_List(PortalId, ModuleId)
            agRanks.Refresh(e.Output)
        End Sub

        Private Sub agRanks_ItemBound(ByVal sender As Object, ByVal e As Modules.ActiveForums.Controls.ItemBoundEventArgs) Handles agRanks.ItemBound
            e.Item(4) = GetDisplay(e.Item(4).ToString, e.Item(1).ToString)
        End Sub
        Public Function GetDisplay(ByVal Display As String, ByVal RankName As String) As String
            Return "<img src=""" & HostURL() & Display.Replace("activeforums/Ranks", "activeforums/images/Ranks") & """ border=""0"" alt=""" & RankName & """ />"
        End Function
        Private Sub BindRankImages()
            Dim FileCollection As String()
            Dim myFileInfo As System.IO.FileInfo
            Dim i As Integer

            FileCollection = IO.Directory.GetFiles(Server.MapPath("~/DesktopModules/ActiveForums/Images/ranks"))
            For i = 0 To FileCollection.Length - 1
                Dim path As String
                myFileInfo = New System.IO.FileInfo(FileCollection(i))
                path = "DesktopModules/activeforums/Images/Ranks/" & myFileInfo.Name
                drpRankImages.Items.Insert(i, New ListItem(myFileInfo.Name, path.ToLowerInvariant()))

            Next
            drpRankImages.Items.Insert(0, New ListItem("[RESX:DropDownDefault]", "-1"))
            ' drpRankImages.Items.Insert(1, New ListItem(Utilities.GetSharedResource("RankCustom.Text"), "0"))
        End Sub
    End Class
End Namespace
